package com.demo.project_template.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.demo.project_template.base.pay.wxpay.vo.DecryptWeChartMsgVO;
import com.demo.project_template.entity.User;
import com.demo.project_template.service.UserService;
import com.demo.project_template.util.JwtUtil;
import com.demo.project_template.vo.request.user.MatchingVO;
import com.demo.project_template.vo.response.R;
import com.demo.project_template.vo.response.LoginResponseVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author 杨玉龙
 * @since 2023-06-19 15:56:44
 */
@Api(tags = "用户模块")
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @ApiOperation("根据userId查询用户信息")
    @PostMapping("/queryById")
    public R<User> queryById(@RequestParam @NotNull Integer userId) {
        User user = userService.getById(userId);
        return R.success(user);
    }

    @ApiOperation("根据userId修改用户信息")
    @PostMapping("/update")
    public R<?> update(@RequestBody User user) {
        userService.updateById(user);
        return R.success();
    }

    @ApiOperation(value = "后台分页查询用户")
    @GetMapping(value = "/page")
    public R<IPage<User>> page(@RequestParam Integer pageNo,@RequestParam Integer pageSize){
        Page<User> page = userService.page(new Page<>(pageNo, pageSize));
        return R.success(page);
    }

    @ApiOperation(value = "首页查询用户")
    @GetMapping(value = "/pageInHome")
    public R<List<User>> pageInHome(@RequestParam Integer pageNo,
                                    @RequestParam Integer pageSize,
                                    @RequestParam Long userId,
                                    @RequestParam String type){

        //todo 逻辑待定
        return null;
    }

    @ApiOperation(value = "匹配")
    @GetMapping(value = "/matching")
    public R<User> matching(MatchingVO matchingVO){
        User user = userService.matching(matchingVO);
        return R.success(user);
    }

    @ApiOperation(value = "获取用户相册")
    @GetMapping(value = "/getUserPicture")
    public R<String> getUserPicture(@RequestParam Long manUserId,
                                    @RequestParam Long womanUserId,
                                    @RequestParam Integer giftId){
        return R.success(userService.getUserPicture(manUserId,womanUserId,giftId));
    }
}
